﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ECommerce.BLL.Order;
using ECommerce.Model.Order;
using Jzy.Core.Dict;
using ECommerce.Common;
using Jzy.Core.Utility;

namespace ECommerce.Web.ECAdmin.Store
{
    public partial class Edit : PageEdit
    {

        private ECStoreBO Store
        {
            get
            {
                return ECStoreBO.Instance<ECStoreBO>();
            }
        }

        

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindDrp();
                if (!string.IsNullOrEmpty(this.PKID))
                {
                    DispInfo();
                }              
                
            }
        }

        private void BindDrp()
        {
            DictBO dict = new DictBO();
            dict.BindListControl(drpArea, (int)DictItem.门店区域);
        }

        private void DispInfo()
        {
            ECStoreInfo info = Store.GetInfo(PKID);
            drpArea.SelectedValue = info.AreaID.ToString();
            Address.Text = info.Address;
            
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {

            ECStoreInfo info = Store.GetInfo(PKID);           

            info.Address = Address.Text;
            info.AreaID = int.Parse(drpArea.SelectedValue);
            info.AreaName = drpArea.SelectedItem.Text;


            Store.Save(info);

            JSUtil.RefreshView();

        }

       
    }
}